﻿using Abp.AutoMapper;
using RMM.Core.Entity.Shops;
using RMM.Core.ShopService;
using RMM.Shops.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RMM.Shops
{
    public class ShopProjectAppService : IShopProjectAppService
    {
        private readonly IShopProjectService _shopProjectService;

        public ShopProjectAppService(IShopProjectService shopProjectService)
        {
            _shopProjectService = shopProjectService;
        }


        public async Task<ShopProjectDto> GetProjectById(int projectId)
        {
            var proj = await _shopProjectService.FirstOrDefaultAsync(p => p.Id == projectId);
            return proj.MapTo<ShopProjectDto>();
        }


        public async Task<List<ShopProjectDto>> GetProjectByShop(int shopId)
        {
            var list = (await _shopProjectService.GetAll()).Where(p => p.ShopId == shopId).ToList();
            return list.MapTo<List<ShopProjectDto>>();
        }
    }
}
